//
//  UIImage+Addition.m
//  测试代码
//
//  Created by ichina on 2017/4/21.
//  Copyright © 2017年 ichina. All rights reserved.
//

#import "UIImage+Addition.h"

@implementation UIImage (Addition)

+ (UIImage *)imageWithOriginImage:(UIImage *)image{
    
    return [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}

+ (UIImage *)wk_drawImageWithImage:(UIImage *)image imageSize:(CGSize)imageSize backgroundColor:(UIColor *)color{
    
    CGRect rect = CGRectMake(0, 0, imageSize.width, imageSize.height);
    //开启上下文
    UIGraphicsBeginImageContext(rect.size);
     //背景填充
    [color setFill];
    //矩形填充
    UIRectFill(rect);
    //实例化一个圆形路径
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:rect];
    //进行路径裁切 后续的绘图都会出现在路径内 外部全部干掉
    [path addClip];
    //绘图 在指定区域内进行拉伸屏幕
    [image drawInRect:rect];
    //绘制内切圆形
    //设置深灰色
    [UIColor.greenColor setStroke];
    //设置线宽
    path.lineWidth = 2;
    //绘制边线
    [path stroke];
    //拿到图片
    UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
    //关闭上下文
    UIGraphicsEndImageContext();
    
    return resultImage;
}

@end
